/*
 * pllist.h - multimedia player playlist GUI
 *
 * Copyright (C) 2010-2011 Serge Begger
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef PLLIST_H
#define PLLIST_H

#include <QWidget>
#include <QVariant>
#include <QtSql>

#include <taglib/fileref.h>
#include <taglib/tag.h>

#include "cueparser.h"
#include "fsys.h"

namespace Ui {
    class pllist;
}

class pllist : public QWidget
{
    Q_OBJECT

public:
    explicit pllist(QWidget *parent = 0);
    ~pllist();
    QString getCurrFileName();
    QString getCurrTitle();
    QString getCurrArtist();
    QString getCurrAlbum();
    QString getCurrLength();
    int getCurrYear();

    bool       isFlacApe();
    int     getStartTime();
    int       getLenTime();

    void setCurrTrack(int);
    int currTrack;
    void addPath(QString);

private:
    Ui::pllist *ui;
    fsys *filesys;
    bool readTags(QString filename, QString &title, QString &artist,
                          QString &album, QString &length,int &year);
    bool parseCue(QString filename);
    bool initDbConnection();
    QSqlDatabase db;
    QSqlRelationalTableModel *modelPlList;
    QVariant getDbValue(int);
    QString lenghtToStr(qint64 lenght);

signals:
    void pllistHide();
    void stopPlay();
    void startPlay();

private slots:
    void on_backButton_pressed();
    void on_addButton_pressed();
    void on_clearButton_pressed();
    void on_delButton_pressed();
    void on_pushButPlUp_pressed();
    void on_pushButPlDw_pressed();
    void on_playButton_pressed();
    void unHide();
    void addFile(QString);    
};

#endif // PLLIST_H
